using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Iacym.Entities;

namespace Iacym.Repository.Mapping
{
    public class MATRIMONIOMap : EntityTypeConfiguration<MATRIMONIO>
    {
        public MATRIMONIOMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            this.Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            // Properties
            // Table & Column Mappings
            this.ToTable("MATRIMONIO");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.EsposoId).HasColumnName("EsposoId");
            this.Property(t => t.EsposaId).HasColumnName("EsposaId");
            this.Property(t => t.FechaMatrimonio).HasColumnName("FechaMatrimonio");
            this.Property(t => t.FechaMatrimonioCivil).HasColumnName("FechaMatrimonioCivil");

            this.HasRequired(t => t.PERSONA)
                .WithMany(t => t.ESPOSAs)
                .HasForeignKey(d => d.EsposaId)
                .WillCascadeOnDelete(false);
            this.HasRequired(t => t.PERSONA1)
                .WithMany(t => t.ESPOSOs)
                .HasForeignKey(d => d.EsposoId)
                .WillCascadeOnDelete(false);

        }
    }
}
